﻿<prism:FlyoutView x:Class="Sumc.Client.ModernUI.Views.CaptchaFlyout"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:local="using:Sumc.Client.ModernUI.Views"
                  xmlns:prism="using:Microsoft.Practices.Prism.StoreApps"
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                  xmlns:converters="using:Sumc.Client.ModernUI.Converters"
                  mc:Ignorable="d"
                  prism:ViewModelLocator.AutoWireViewModel="true">
    <Grid VerticalAlignment="Stretch"
              Background="#d1d1d1">

        <!-- Root grid definition -->
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <!-- Header area for panel -->
        <Grid Grid.Row="0"
                  Background="{StaticResource DefaultItemBackground}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Button Command="{Binding GoBackCommand}"
                        x:Uid="PrivacyPolicyFlyoutBackButton"
                        Margin="30,40,0,0"
                        VerticalAlignment="Center"
                        Style="{StaticResource SnappedBackButtonStyle}"/>
            <TextBlock Grid.Column="1"
                       Margin="10,5,0,0"
                       FontFamily="Segoe UI"
                       FontWeight="SemiLight"
                       FontSize="24"
                       TextWrapping="Wrap"
                       VerticalAlignment="Center"
                       x:Uid="CaptchaFlyoutTextBlockTitle" />
        </Grid>

        <Grid Grid.Row="1"
              Margin="50, 30, 50, 30"
              Visibility="{Binding CaptchaUrl, Converter={StaticResource NullToVisibilityConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <ProgressBar IsIndeterminate="{Binding LoadingData}"
                         Width="250" 
                         Height="30"
                         Visibility="{Binding LoadingData, Converter={StaticResource BooleanToVisibilityConverter}}"
                         Style="{StaticResource ProgressBar}" />
            <TextBlock Grid.Row="1"
                       x:Uid="CaptchaFlyoutTextBlockTextPart1"
                       HorizontalAlignment="Center"
                       Foreground="{StaticResource DefaultDarkBrush}"
                       FontSize="14"/>
            <TextBlock Grid.Row="2"
                       x:Uid="CaptchaFlyoutTextBlockTextPart2"
                       HorizontalAlignment="Center"
                       FontSize="14"
                       Foreground="{StaticResource DefaultDarkBrush}"
                       Margin="0,0,0,10"/>
            <TextBlock Grid.Row="3"
                       x:Uid="CaptchaFlyoutTextBlockWrongCode"
                       Foreground="{StaticResource DefaultDarkBrush}"
                       HorizontalAlignment="Center"
                       FontSize="14"
                       Visibility="{Binding IsCaptchaIncorrectlyEntered, Converter={StaticResource BooleanToVisibilityConverter}}"
                       Margin="0,0,0,10" />

            <Grid Grid.Row="4">
                <Grid.RowDefinitions>
                    <RowDefinition Height="45" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Image Source="{Binding CaptchaUrl}"
                       Grid.Column="0" />
                <TextBox Text="{Binding Code, Mode=TwoWay}"
                         IsEnabled="{Binding LoadingData, Converter={StaticResource InvertBooleanConverter}}"
                         FontSize="24"
                         Margin="10,0,3,0"
                         HorizontalAlignment="Stretch"
                         Grid.Column="1"/>
                <Button x:Uid="CaptchaFlyoutButtonSend"
                        HorizontalAlignment="Stretch"
                        Command="{Binding PostCaptcha}"
                        IsEnabled="{Binding LoadingData, Converter={StaticResource InvertBooleanConverter}}"
                        Grid.Row="1"
                        Foreground="{StaticResource DefaultDarkBrush}"
                        Grid.ColumnSpan="2"
                        Margin="0,10,0,0"/>
            </Grid>
        </Grid>
    </Grid>
</prism:FlyoutView>
